             package com.java.diagnostics.visualizer.recommender;
             
             import com.java.diagnostics.visualizer.data.AggregateData;
             import com.java.diagnostics.visualizer.data.DataPoint;
             import com.java.diagnostics.visualizer.data.StructuredData;
             import com.java.diagnostics.visualizer.data.TupleData;
             import com.java.diagnostics.visualizer.parser.vgc.constants.VGCGCReasons;
             import com.java.diagnostics.visualizer.recommender.util.RecommendationLabels;
             import java.util.Map;
             
             public class CalculateGCMode
               extends RecommendationBase
               implements Recommendation
             {
               public void recommend(AggregateData data)
               {
                 String mode = null;
                 String modeLabel = RecommendationLabels.GC_MODE;
                 
                 StructuredData attributes = data
                   .getStructuredData("VGCLabels.gc.attributes");
                 
                 if (attributes != null) {
                   String gcPolicy = (String)attributes.getContents().get("gcPolicy");
                   
                   if (gcPolicy != null) {
                     mode = gcPolicy.substring(11);
                     addToSummary(data, modeLabel, mode);
                     return;
                   }
                 }
                 
                 TupleData nurseryTotal = data.getTupleData("VGCLabels.nursery.size");
                 
                 if (!isIBM(data))
                 {
                   TupleData edenSize = data
                     .getTupleData("OracleVGCLabels.eden.size.before");
                   if (edenSize != null) {
                     mode = "G1";
                   } else {
                     mode = null;
                   }
                 }
                 else if ((nurseryTotal != null) && (nurseryTotal.length() > 0)) {
                   mode = "gencon";
                 } else {
                   TupleData reasonRecord = data
                     .getTupleData("VGCLabels.gc.reasons");
                   if ((reasonRecord != null) && (reasonRecord.length() > 0))
                   {
                     TupleData kickoffRecord = data
                       .getTupleData("VGCLabels.intended.kickoff");
                     
                     if ((kickoffRecord != null) && (kickoffRecord.length() > 0)) {
                       mode = "optavgpause";
                     }
                     else
                     {
                       DataPoint[] points = reasonRecord.getDataPoints();
                       for (int i = 0; i < points.length; i++) {
                         double reason = points[i].getRawY();
                         if (VGCGCReasons.nameToInt("con") == reason) {
                           mode = "optavgpause";
                         } else if ((
                           VGCGCReasons.nameToInt("heartbeat") == reason) || 
                           (
                           VGCGCReasons.nameToInt("synchgc") == reason) || 
                           (VGCGCReasons.nameToInt("priogc") == reason)) {
                           mode = "metronome";
                         } else if (VGCGCReasons.BAL_INT == reason) {
                           mode = "balanced";
                         }
                       }
                       
                       if (mode == null) {
                         mode = "optthruput";
                       }
                     }
                   }
                 }
                 
                 if (mode != null) {
                   addToSummary(data, modeLabel, mode);
                 }
               }
             }


